package com.zcj.test.guide;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;


/**
 * Created by binIoter on 16/6/17.
 */
public class MutiComponent implements Component {
  private int mIndex;
  private int mScrollViewOffset;

  public MutiComponent(int index, int offset) {
    mIndex = index ;
    mScrollViewOffset = offset;
  }

  @Override
  public View getView(LayoutInflater inflater) {
    LinearLayout ll = new LinearLayout(inflater.getContext());
    LinearLayout.LayoutParams param =
        new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    ll.setOrientation(LinearLayout.HORIZONTAL);
    ll.setLayoutParams(param);
//    TextView textView = new TextView(inflater.getContext());
//    textView.setTextColor(Color.parseColor("#ffffff"));
//    textView.setTextSize(20);
    ImageView imageView = new ImageView(inflater.getContext());
    switch (mIndex){
      case 1:
        imageView.setImageResource(R.mipmap.ic_launcher);
        break;
      case 2:
        imageView.setImageResource(R.mipmap.ic_launcher);
        break;
      case 3:
        imageView.setImageResource(R.mipmap.ic_launcher);
        break;
      case 4:
        imageView.setImageResource(R.mipmap.ic_launcher);
        break;
    }
    ll.removeAllViews();
//    ll.addView(textView);
    ll.addView(imageView);
    return ll;
  }

  @Override
  public int getAnchor() {
    return Component.ANCHOR_RIGHT;
  }

  @Override
  public int getFitPosition() {
    return Component.FIT_CENTER;
  }

  @Override
  public int getXOffset() {
    return 20;
  }

  @Override
  public int getYOffset() {
    return 0;
  }

  @Override
  public int getScrollViewYOffset() {
    if (mIndex == 2){
      return mScrollViewOffset;
    }
    return 0;
  }

}
